<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />
  
  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />
  
  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>
  
  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>
  
  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
	  <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
	    <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
	  </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />
    
    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>

  <UsingTask
  TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
  AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.CreateRelease"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.UploadFiles"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.WebServices.Client.Tasks.GetDateTime"
    AssemblyFile="DevLibraries\CodePlex.WebServices.Client.dll"/>
  <UsingTask
    TaskName="CodePlex.MSBuildTasks.RegexReplace"
    AssemblyFile="DevLibraries\CodePlex.MSBuildTasks.dll"/>
  <UsingTask
    TaskName="XunitExt.Runner.MSBuild.xunit"
    AssemblyFile="DevLibraries\xunitext.runner.msbuild.dll"/>

  <Target Name="Cruise" DependsOnTargets="Clean;DbInitUpgrade;SetVersionNumber;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip" />
  <Target Name="CruiseDaily" DependsOnTargets="Clean;BuildWiki;UnitTestWiki;Build;UnitTest;CreateBuildFiles;Zip;UploadZip" />
  <Target Name="Wiki" DependsOnTargets="BuildWiki;UnitTestWiki"/>
  <Target Name="FullTest" DependsOnTargets="Clean;DbInitUpgrade;BuildWiki;UnitTestWiki;Build;UnitTest;TeamFoundationServerTest" />
  <Target Name="RedmondTestNoAD" DependsOnTargets="Clean;DbInitUpgrade;BuildNoDeploy;UnitTest" />
  <Target Name="CreateBuild" DependsOnTargets="Clean;DbInitUpgrade;Build;UnitTest;CreateBuildFiles" />
  <Target Name="Test" DependsOnTargets="DbInitUpgrade;UnitTest;TeamFoundationServerTest" />
  <Target Name="JustTests" DependsOnTargets="DbInitUpgrade;UnitTest" />
  <Target Name="BuildCodeGallery" DependsOnTargets="DbInitUpgrade;BuildNoDeploy;DeployCodeGallery" />

  <Target Name="CleanDb" DependsOnTargets="DbInitEmpty" />
  <Target Name="DevDb" DependsOnTargets="DbInitDev" />
  <Target Name="UpgradeDb" DependsOnTargets="DbInitUpgrade" />

  <Target Name="CreatePackages" DependsOnTargets="CreateBuildFiles;Zip" />

  <PropertyGroup>
    <ZipStoragePath>D:\Builds\Zips\CodePlex</ZipStoragePath>
    <SourceZipStoragePath>D:\Builds\Source</SourceZipStoragePath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(ccnetlabel)' == ''">
    <ccnetlabel>0</ccnetlabel>
  </PropertyGroup>

  <ItemGroup>
    <DatabaseAlterScripts Include="DatabaseScripts\AlterScripts\*.*" />
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Clean" />
    <RemoveDir Directories="BuildFiles" />
    <Delete Files="@(TestResults)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="CommunityFoundation.sln" Targets="Build" />
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="DeployCodeGallery">
    <RemoveDir Directories="CodeGallery.WebSite_deploy" />
    <RemoveDir Directories="CodeGallery.WebSite_temp" />

    <CreateItem Include="CodePlex.WebSite\**\*.*" Exclude="**\bin\*.*;**\CodePlex.WebSite.*;**\_tfs\**;**\..svnbridge\**;**\.svnbridge;CodePlex.WebSite\Services\ProjectInfoService.*;CodePlex.WebSite\Services\ReleaseService.*;CodePlex.WebSite\Services\SourceControlService.*;CodePlex.WebSite\Services\SourceDownloadService.*;CodePlex.WebSite\Views\**;CodePlex.WebSite\ViewData\**;CodePlex.WebSite\Controllers\**">
      <Output TaskParameter="Include" ItemName="WebSiteFilesForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite\**\*.*" Exclude="**\_tfs\**;**\..svnbridge\**;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDNForCodeGallery"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>

    <Copy SourceFiles="@(WebSiteFilesForCodeGallery)" DestinationFiles="@(WebSiteFilesForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDNForCodeGallery)" DestinationFiles="@(WebSiteFilesMSDNForCodeGallery->'CodeGallery.WebSite_temp\%(RecursiveDir)%(Filename)%(Extension)')" />

    <AspNetCompiler VirtualPath="CodeGallery.WebSite_temp\CodeGallery.WebSite.csproj" PhysicalPath="CodeGallery.WebSite_temp" TargetPath="CodeGallery.WebSite_deploy" Updateable="true" Debug="true" Force="true" />

    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'CodeGallery.WebSite_deploy\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')"  />
  </Target>

  <Target Name="BuildWiki">
    <MSBuild Projects="CodePlex.Wiki.sln" Targets="Clean;Build"/>
  </Target>

  <Target Name="UnitTestWiki">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /xml=Test.CodePlex.Wiki.results.xml Test.CodePlex.Wiki\bin\Debug\Test.CodePlex.Wiki.dll" />
  </Target>

  <Target Name="PreCompile">
    <Exec Command="%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v CodePlex.WebSite\CodePlex.WebSite.csproj -p CodePlex.WebSite -f -c -d CodePlex.WebSite_deploy\DebugNoUpdate\" />
  </Target>

  <Target Name="BuildNoDeploy">
    <MSBuild Projects="CommunityFoundationNoDeploy.sln" Targets="Build" />
  </Target>

  <Target Name="DbInitDev" DependsOnTargets="DbInitDropAndCreate;DbInitLoadTestData;DbInitUpgrade;DbInitLoadDevData;DbInitUpgradePasswordHashes" />
  <Target Name="DbInitEmpty" DependsOnTargets="DbInitDropAndCreate;DbInitUpgrade" />

  <Target Name="DbInitDropAndCreate">
    <Exec Command="osql    -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i DropTables.sql"            WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateTables.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i CreateFullTextIndexes.sql" WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadReferenceData.sql"     WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgradePasswordHashes">
    <Exec Command="Tools\bin\UpgradePasswordHashes $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword)" />
  </Target>

  <Target Name="DbInitLoadTestData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadTestData.sql"          WorkingDirectory="DatabaseScripts" />
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i WikiSearchableContent.sql" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitLoadDevData">
    <Exec Command="osql -b -n -U $(SqlUser) -P $(SqlPassword) -S $(SqlServer) -d $(SqlDatabase) -i LoadDevData.sql > nul" WorkingDirectory="DatabaseScripts" />
  </Target>

  <Target Name="DbInitUpgrade">
    <Exec Command="Tools\bin\DatabaseUpgrader $(SqlServer) $(SqlDatabase) $(SqlUser) $(SqlPassword) DatabaseScripts\AlterScripts" />
  </Target>

  <Target Name="UnitTest" DependsOnTargets="BuildNoDeploy">
    <xunit Assembly="UnitTest\DataModel.Tests\bin\Debug\CodePlex.DataModel.Tests.dll" Xml="Test.CodePlex.DataModel.results.xml"/>
    <xunit Assembly="Test.UnitTest\bin\Debug\Test.UnitTest.dll" Xml="Test.UnitTest.results.xml"/>
  </Target>

  <Target Name="ActiveDirectoryTest">
    <Exec Command="DevLibraries\nunit-console.exe /nologo /include=ActiveDirectory /xml=Test.IntegrationTest.ActiveDirectory.results.xml Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="TeamFoundationServerTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,SmokeTest Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="SmokeTest">
    <Exec Command="DevLibraries\nunit-console.exe /noshadow /xml=Test.IntegrationTest.results.xml /exclude=ActiveDirectory,ReadOnlyTests,ReadWriteTests Test.IntegrationTest\bin\Debug\Test.IntegrationTest.dll" />
  </Target>

  <Target Name="Zip">
    <Exec Command="..\Tools\bin\zip.exe -r -9 $(ZipStoragePath)\CodePlex-build-$(ccnetlabel).zip *.*" WorkingDirectory="BuildFiles" />
  </Target>

  <Target Name="UploadZip">
    <GetDateTime Format="yyyy-MM-dd">
      <Output PropertyName="UploadDate" TaskParameter="Text" />
    </GetDateTime>
    <Copy SourceFiles="Dist\CodePlex.zip" DestinationFiles="Dist\Nightly Build $(UploadDate).zip" />
    <UploadFiles
      BaseUrl="http://codeplex-intern"
      ProjectName="CodePlex" ReleaseName="Nightly Builds"
      ReleaseFiles="Dist\Nightly Build $(BuildDate).zip"
      Username="cppair01" Password="Pass@word1"
    />
    <Delete Files="Dist\Nightly Build $(BuildDate).zip" />
  </Target>

  <Target Name="SetVersionNumber">
    <GetDateTime Format="yyyy.M.d">
      <Output PropertyName="VersionBuildDate" TaskParameter="Text" />
    </GetDateTime>
    <RegexReplace
      Pattern='Version\("\d+\.\d+\.\d+\.\d+"\)'
      Replacement='Version("$(VersionBuildDate).$(ccnetlabel)")'
      Files='GlobalAssemblyInfo.cs'/>
  </Target>

  <ItemGroup>
    <TestResults Include="Test.*.results.xml" />
  </ItemGroup>

  <Target Name="CreateBuildFiles">
    <CreateItem Include="BasicProcessTemplate\**\*.*" Exclude="BasicProcessTemplate\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BasicProcessTemplateFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite_deploy\Debug\**\*.*" Exclude="CodePlex.WebSite_deploy\Debug\web.config;CodePlex.WebSite_deploy\Debug\Project\Download\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="WebSiteFiles"/>
    </CreateItem>
    <CreateItem Include="CodePlex.WebSite\Project\Download\Global.asax">
      <Output TaskParameter="Include" ItemName="FileDownloadAppStartupFiles" />
    </CreateItem>
    <CreateItem Include="CodeGallery.WebSite_deploy\**\*.*" Exclude="CodeGallery.WebSite_deploy\web.config;CodeGallery.WebSite_deploy\Project\Download\web.config">
      <Output TaskParameter="Include" ItemName="WebSiteFilesMSDN"/>
    </CreateItem>
    <CreateItem Include="CodePlex.Admin.WebServices_deploy\Debug\**\*.*" Exclude="**\web.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="AdminWebServiceFiles"/>
    </CreateItem>
    <CreateItem Include="TaskService\bin\Debug\*.*;TaskService\Scripts\*.*" Exclude="**\StatisticsUpdateService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="StatsUpdateServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\bin\Debug\*.*" Exclude="**\ProjectCreationService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ProjectCreationServiceFiles"/>
    </CreateItem>
    <CreateItem Include="ProjectCreationService\VsipUnit\*.*" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="VsipUnitFiles"/>
    </CreateItem>
    <CreateItem Include="BackupTestingService\bin\Debug\*.*" Exclude="**\BackupTestingService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="BackupTestingServiceFiles"/>
    </CreateItem>
    <CreateItem Include="MonitorService\bin\Debug\*.*" Exclude="**\MonitorService.exe.config;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="MonitorServiceFiles"/>
    </CreateItem>
    <CreateItem Include="Tools\Bin\*.exe*;Tools\Bin\*.dll;" Exclude="**\.svnbridge;**\_tfs">
      <Output TaskParameter="Include" ItemName="ToolsFiles"/>
    </CreateItem>
    <CreateItem Include="DeploymentScripts\Environment\**\*.*" Exclude="DeploymentScripts\Environment\**\.svn\**\*.*;**\.svnbridge">
      <Output TaskParameter="Include" ItemName="EnvironmentFiles"/>
    </CreateItem>
    <CreateItem Include="Config\*.template" Exclude="**\.svnbridge">
      <Output TaskParameter="Include" ItemName="ConfigFiles"/>
    </CreateItem>
    <CreateItem Include="Forges.Services.csproj_deploy\Debug\**\*.*" Exclude="**\.svnbridge;Forges.Services.csproj_deploy\Debug\web.config;Forges.Services.csproj_deploy\Debug\Forges.Services.csproj.*">
      <Output TaskParameter="Include" ItemName="ForgesFiles" />
    </CreateItem>

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\WEB-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\WEB-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\WEB-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFiles)" DestinationFiles="@(WebSiteFiles->'BuildFiles\WEB-TIER\CommunitySite\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(WebSiteFilesMSDN)" DestinationFiles="@(WebSiteFilesMSDN->'BuildFiles\WEB-TIER\CodeGallery\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(FileDownloadAppStartupFiles)" DestinationFiles="@(FileDownloadAppStartupFiles->'BuildFiles\WEB-TIER\CommunitySite\Project\Download\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MonitorServiceFiles)" DestinationFiles="@(MonitorServiceFiles->'BuildFiles\WEB-TIER\MonitorService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesWeb.bat" DestinationFiles="BuildFiles\WEB-TIER\CreateConfigFiles.bat" />
    <Copy SourceFiles="@(ForgesFiles)" DestinationFiles="@(ForgesFiles->'BuildFiles\WEB-TIER\Forges\%(RecursiveDir)%(Filename)%(Extension)')" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\ADMIN-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\ADMIN-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\ADMIN-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BasicProcessTemplateFiles)" DestinationFiles="@(BasicProcessTemplateFiles->'BuildFiles\ADMIN-TIER\BasicProcessTemplate\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AdminWebServiceFiles)" DestinationFiles="@(AdminWebServiceFiles->'BuildFiles\ADMIN-TIER\CommunityWebService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ProjectCreationServiceFiles)" DestinationFiles="@(ProjectCreationServiceFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(VsipUnitFiles)" DestinationFiles="@(VsipUnitFiles->'BuildFiles\ADMIN-TIER\ProjectCreationService\VsipUnit\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StatsUpdateServiceFiles)" DestinationFiles="@(StatsUpdateServiceFiles->'BuildFiles\ADMIN-TIER\StatsUpdateService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesAdmin.bat" DestinationFiles="BuildFiles\ADMIN-TIER\CreateConfigFiles.bat" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\DATA-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DatabaseScripts\CreateTables.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateTables.sql" />
    <Copy SourceFiles="DatabaseScripts\CreateFullTextIndexes.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\CreateFullTextIndexes.sql" />
    <Copy SourceFiles="DatabaseScripts\LoadReferenceData.sql" DestinationFiles="BuildFiles\DATA-TIER\SQLDatabaseScripts\LoadReferenceData.sql" />
    <Copy SourceFiles="@(DatabaseAlterScripts)" DestinationFolder="BuildFiles\DATA-TIER\SqlDatabaseScripts\AlterScripts" />

    <Copy SourceFiles="@(ToolsFiles)" DestinationFiles="@(ToolsFiles->'BuildFiles\MONITOR-TIER\Tools\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(EnvironmentFiles)" DestinationFiles="@(EnvironmentFiles->'BuildFiles\MONITOR-TIER\Environment\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ConfigFiles)" DestinationFiles="@(ConfigFiles->'BuildFiles\MONITOR-TIER\Config\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BackupTestingServiceFiles)" DestinationFiles="@(BackupTestingServiceFiles->'BuildFiles\MONITOR-TIER\BackupTestingService\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="DeploymentScripts\CreateConfigFilesMonitor.bat" DestinationFiles="BuildFiles\MONITOR-TIER\CreateConfigFiles.bat" />
  </Target>

</Project>
